# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=tmux
pkgver=3.3a_git20230428
pkgrel=0
_gitrev=fbe6fe7f55cfc2a32f9cee4cb50502a53d3ce8bb
pkgdesc="Tool to control multiple terminals from a single terminal"
url="https://tmux.github.io"
arch="all"
license="ISC"
depends="ncurses-terminfo-base"
makedepends="autoconf automake bison flex libtool libevent-dev ncurses-dev"
subpackages="$pkgname-doc"
source="https://github.com/tmux/tmux/archive/$_gitrev.tar.gz"
builddir="$srcdir/tmux-$_gitrev"

# secfixes:
#   3.1c-r0:
#     - CVE-2020-27347

prepare() {
	default_prepare

	./autogen.sh
}

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	install -D -m644 example_tmux.conf \
		"$pkgdir"/usr/share/doc/$pkgname/examples/$pkgname.conf
	local file; for file in CHANGES README; do
		install -m644 "$file" "$pkgdir"/usr/share/doc/$pkgname/
	done
}

sha512sums="
5bec2643a9e6117d1ae354a1ea1954d5bf44fd2fa4ad5553fdc404a43feb9bdf12ceb40ebdc5450c7fe8dcafebabd2102aa1732860b26a364f8a6a45e3e09d7c  fbe6fe7f55cfc2a32f9cee4cb50502a53d3ce8bb.tar.gz
"
